<style>

    ul.sample li {
        line-height: 2;
        font-size: 14px;
    }

    .srouce-bar {
        padding: 10px 20px;
        background: #fafafa;
        border: 1px solid #ddd;
        border-width: 1px 0;
    }

    .srouce-bar h4 {
        margin: 0;
        text-align: left;
        color: #2575ed;
        font-weight: bold;
    }

    #result {
        display: inline-block;
        width: 100%;
        padding: 10px;
    }

    .remark {
        color: gray;
        font-size: 12px;
    }

    .source {
        max-height: 400px;
        overflow-y: scroll;
    }
</style>
<div class="container-fluid" data-ng-controller="sampleCtrl">
    <div class="col-md-2 portlet" style="background: #fafafa;">
        <div class="portlet-title">
            <div class="caption" style="margin-left: 10px;">
                示例
            </div>
        </div>
        <div class="portlet-body">
            <ul class="sample">
                <!--<li><a href="#/sample/combo" >下拉菜单</a></li>-->
                <!--<li ui-sref=".combo"><a href="" >下拉菜单1</a></li>-->
                <li ng-repeat="sample in _samples" ng-click="go(sample)">
                    <a href="">{{sample.title}}</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="col-md-10" ng-show="_showing">
        <div style="margin-left: 10px; border: 1px solid #ddd;">
            <!--<div class="portlet-title">-->

            <!--</div>-->
            <div id="result" class="portlet-body">
                <!--<div ui-view=""/>-->
            </div>

            <div class="srouce-bar">
                <h4>源码</h4>
            </div>

            <div class="portlet-body source">
                <pre class="prettyprint linenums" style="border: none;" id="source">
                </pre>
            </div>
        </div>
    </div>
</div>

<script>

    function sampleCtrl($rootScope, $scope, $compile, $templateCache, Page) {

        $rootScope._samples = [];
        $rootScope._samples.push({title: '下拉菜单', url: 'views/sample/combo.html'});
        $rootScope._samples.push({title: '文件上传', url: 'views/sample/uploader.html'});
        $rootScope._samples.push({title: '弹出层', url: 'views/sample/modal.html'});
        $rootScope._samples.push({title: '人员选择', url: 'views/sample/userSelect.html'});
        $rootScope._samples.push({title: '时间选择', url: 'views/sample/datepicker.html'});

        $scope.go = function (sample) {
            if ($templateCache.get(sample.url)) {
                $scope.show($templateCache.get(sample.url));
            } else {
                Page.ajaxGet(sample.url, null, null, function (resp) {
                    $scope.show(resp);
                });
            }
        }

        $scope.show = function (html) {
            $('#result').empty().append(html);
            $compile($('#result').contents())($scope);

            html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
                    .replace(
                    /&lt;script src[\s\S]*?&gt;&lt;\/script&gt;|&lt;!--\?[\s\S]*?--&gt;|&lt;pre\b[\s\S]*?&lt;\/pre&gt;/g,
                    '<span class="operative">$&</span>');
            $('#source').empty().removeClass('prettyprinted').append(html);
            prettyPrint();

            $scope._showing = true;
        }
    }

</script>






